import { writable } from 'svelte/store';

//是否为管理ui界面
export const admin_state = writable<boolean>(false);

//导航栏
export const url = writable<string>("Genshin");
//侧边栏
export const sidebar = writable<boolean>(true);
//主页设备ui遍历
export const myCardArray = writable<Array<number>>([]);

//设备状态
export const Power = writable<boolean>(false);
export const STM32_Power = writable<boolean>(false);

export const main_grid_cols = writable<number>(3);

//连接状态
export enum LinkStatus {
  Online = 'online',
  Offline = 'offline',
  Reconnecting = 'reconnecting'
}
//stm32连接状态
export const Stm32 =  writable<LinkStatus>(LinkStatus.Offline);
//电机连接状态
export const Motor_1 = writable<LinkStatus>(LinkStatus.Offline);
export const Motor_2 = writable<LinkStatus>(LinkStatus.Offline);
//ad7606连接状态
export const AD7606 = writable<LinkStatus>(LinkStatus.Offline);

//stm32图表
export const Stm32_chart = writable<boolean>(true);
//电机图表
export const Motor_1_chart = writable<boolean>(true);
export const Motor_2_chart = writable<boolean>(true);
//电压电流图表
export const V_I_chart = writable<boolean>(false);

//电机角度
export const Motor_1_angle = writable<number>(0);
export const Motor_2_angle = writable<number>(0);
//电机连接超时
export const Motor_1_outtime = writable<boolean>(false);
export const Motor_2_outtime = writable<boolean>(false);

//设备控制状态
export const shebeiState = writable<boolean>(true);
//监控台状态
export const jiankongState = writable<boolean>(true);
//监视台CheckBox
export const SwCheckbox = writable<Array<boolean>>([])
//用户的运动模式选择
export const motionmode = writable<string>("")
//运动模式栏状态
export const motionmodeState = writable<boolean>(true);
//训练工作状态
export const train_working = writable<boolean>(false);
export const train_end = writable<boolean>(false);
//等待本次运行停止状态
export const cancelmotioning= writable<boolean>(false);
//子选项状态
export const motionmodeListgroupItemState = writable<Array<boolean>>([false,false,false,false]);
export const motionmodeListgroupItemtext = writable<Array<string>>(["","","",""]);
export const motionmodeListgroupItemDataState = writable<Array<boolean>>([false,false,false,false]);
//用户的运动模式子项
// interface motionmodeitemItem {
//   name: string;
//   current: boolean;
// }
// export const motionmodeitem = writable<Array<motionmodeitemItem>>([{name: "sw", current: true}, {name: "dawa", current: false}]);

//端口设置
export interface Serial_select_type {
  value: string;
  name: string;
}
export const Serial_select = writable<Serial_select_type[]>();
export const Serial_select_value = writable<string>();
//波特率设置
export const Baud_rate = writable<number>(19200);
//设置load_collection发送频率
export const send_rate = writable<number>(10);
//防止link()被多次调用
export const link_working = writable<boolean>(false); 

//canvas电机角度
export const angle1 = writable(0);
export const angle2 = writable(0);

//demo
export const intervalId = writable<number>(0);
export const demo_state = writable<boolean>(false);
export const ani_speed = writable<number>(240);

export const mo1 = writable<Array<number>>([])
export const mo2 = writable<Array<number>>([])

export const tor1 = writable<Array<number>>([])
export const tor2 = writable<Array<number>>([])

//临时串口字符
export const temp_str = writable<string>();

export const x_labels_num = writable<number>(1);

//运动模式临时缓存变量
export const collection_motion_name = writable<string>("")
export const start_collection_mo1 = writable<Array<number>>([])
export const start_collection_mo2 = writable<Array<number>>([])

export const ListgroupItem_file_prefix = writable<number>(-1);

export const start_collection_state = writable<boolean>(false);